<script>
	import config from '@/config.js';
	import Vue from 'vue'
	export default {
		async onLaunch() {
            try {
                if (config.developFlag && process.env.NODE_ENV === 'development') {
                    Vue.prototype.$baseUrl = config.baseUrl;
                } else {
                    const isIntranet = await this.checkIntranetByRequest();					
                    Vue.prototype.$baseUrl = isIntranet ? config.intraUrl : config.extraUrl;
                }
                // console.log('App Launch')
            } catch (e) {
                console.error('onLaunch error:', e)
            }
        },
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		
		methods: {
			// 通过请求内网地址检测
			checkIntranetByRequest() {
			  return new Promise((resolve) => {
				uni.request({
				  url: config.intraUrl + '/admin', // 内网检测接口
				  method: 'GET',
				  timeout: 1500,
				  success: () => resolve(true),
				  fail: () => resolve(false)
				});
			  });
			},
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
